package com.shopweb.service.impl;

import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.shop.bean.Shop;
import com.shopweb.dao.ShopMapper;
import com.shopweb.service.IShopService;

import shopBean.common.Enum.StatusAll;
import shopBean.common.utils.DateCommonUtils;
import shopBean.common.utils.UUIDGenerator;

import java.util.Map;

@Service("shopService")
@Transactional
public class ShopServiceImpl implements IShopService {
	@Autowired
	private ShopMapper shopMapper;
	@Override
	@Transactional
	public int insert(Shop shop) {
		shop.setCreateDate(DateCommonUtils.getCurrent());
		shop.setId(UUIDGenerator.generate());
		shop.setSalesNum(0);
		shop.setStatus(StatusAll.normal);
		return shopMapper.insert(shop);
	}
	@Override
	public Shop getShopById(String id) {
		// TODO Auto-generated method stub
		return shopMapper.getShopById(id);
	}

	@Override
	public int updateStatusById(Map<String, Object> params) {
		return shopMapper.updateStatusById(params);
	}
}
